<?php 
$companyid=$session->read("companyid");
$user=$session->read('User');
$isflag=$action->checkPermissions($user,$companyid);
?>
<?php echo $javascript->link('jquery.timelinr-0.9.4.js');?>
<script type="text/javascript">
	$(function(){
		$().timelinr({
			orientation: 'horizontal',
			containerDiv: '#timeline',
			datesDiv: '#dates',
			datesSelectedClass: 'selected',
			datesSpeed: 500,
			issuesDiv : '#issues',
			issuesSelectedClass: 'selected',
			issuesSpeed: 200,
			issuesTransparency: 0.2,
			issuesTransparencySpeed: 500,
			prevButton: '#prev',
			nextButton: '#next',
			arrowKeys: 'false',
			startAt: 1,
			autoPlay: 'false',
			autoPlayDirection: 'forward',
			autoPlayPause: 2000
	 	});
	});
</script>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>
			<?php 
			$companyname=$session->read("companyname");
			echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
			?>
		</h2>
		<div class="clear"></div>
	</div>
   	<?php 
    	//if($isflag){
    		echo '<div class="right item_add_btn">';
			echo $html->link(__("Add",true),'editpatent');
			echo '</div>';
		//}else{
			//echo '<div class="right enableaction">';
			//echo "<a>添加</a>";
			//echo '</div>';
		//}
	?>
    <?php
    $cuser=$session->read('User'); 
	?>
    <div class="clear"></div>
    <div class="right_sidt_head_screen">
		<div class="right display_by_year_btn"><?php echo $html->link('返回',"/companys/patents/",null,null); ?></div>
		<div class="clear"></div>
	</div>
</div>
<div class="right_side_scollbar">
	<div class="detail_info_panel">
        <div class="time_line_panel" id='time_panel'>
        	<div class="time_line_area" id="timeline">
            	<ul id="dates">
            	 	<?php if($objyears){
            	 		foreach($objyears as $years){
            	 		$y=$years["year"];
            	 		?>
            	 			<li><a href="#<?php echo $y; ?>"><?php echo $y; ?></a></li>
            	 		<?php
            	 		}
            	 	}
            	 	?>
                </ul>
                <ul id="issues">
                  
                    <?php foreach($objyears as $years){ 
                   						$y=$years["year"];
						                $m=0; $n = 0;$l=0;$k=0;
                    ?>
                    <li id="<?php echo $y; ?>">
                        <div class="issue_details">
                    	
                        	<div class="right_sidt_screen_by_year">
                        		<div class="right_side_head_line">
                        		<div class="right_side_head_line">
                        			<div class="left per_screen_by_time">
                        				<div class="left screen_condition">
                        					申请中：
                        				</div>
                        				<div class="clear"></div>
                        			</div>
                        			<?php 
	                        			$objtype=$years["type"];
	                        			foreach($objtype["0"] as $key=>$type){?>
	                        			<div class="left per_screen_by_time">
	                        				<div class="left screen_condition">
	                        					<?php echo $key;?>：
	                        				</div>
	                        				<div class="left screen_counts"><?php echo $type;?>个</div>
	                        			</div>
                        			 <?php }?>
                        			
                        			<div class="left per_screen_by_time">
                        				<div class="left screen_condition">
                        					已受理：
                        				</div>
                        				<div class="clear"></div>
                        			</div>
                        			<?php 
	                        			$objtype=$years["type"];
	                        			foreach($objtype["1"] as $key=>$type){?>
	                        			<div class="left per_screen_by_time">
	                        				<div class="left screen_condition">
	                        					<?php echo $key;?>：
	                        				</div>
	                        				<div class="left screen_counts"><?php echo $type;?>个</div>
	                        			</div>
                        			 <?php }?>
                        			
                        			
                        			<div class="left per_screen_by_time">
                        				<div class="left screen_condition">
                        					已授权：
                        				</div>
                        				<div class="clear"></div>
                        			</div>
                        			<?php 
	                        			$objtype=$years["type"];
	                        			foreach($objtype["2"] as $key=>$type){?>
	                        			<div class="left per_screen_by_time">
	                        				<div class="left screen_condition">
	                        					<?php echo $key;?>：
	                        				</div>
	                        				<div class="left screen_counts"><?php echo $type;?>个</div>
	                        			</div>
                        			 <?php }?>
                        			
                        			<div class="left per_screen_by_time">
                        				<div class="left screen_condition">
                        					已购买：
                        				</div>
                        			</div>	
                        			<?php 
	                        			$objtype=$years["type"];
	                        			foreach($objtype["3"] as $key=>$type){?>
	                        			<div class="left per_screen_by_time">
	                        				<div class="left screen_condition">
	                        					<?php echo $key;?>：
	                        				</div>
	                        				<div class="left screen_counts"><?php echo $type;?>个</div>
	                        			</div>
                        			 <?php }?>
                        			<div class="clear"></div>
                        		</div>
                    	
                        	  <div class="items_list" id='panel'>
						        	<table>
						            	<tr>
						            		<th><?php echo '知识产权'; ?></th>
						                    <th><?php echo '产权类型' ;?></th>
						                    <th><?php echo '产权状态/时间' ;?></th>
                    						<th><?php echo '创建时间'; ?></th>
						                    <th><?php __("Action")?></th>
						                </tr>
						                <?php 
						                $cuser=$session->read('User');
										foreach($timepatents[$y] as $patent){
											$id=$patent["CompanyPatent"]["id"];
											echo "<tr class='per_list'>";
											echo "<td>".$html->link($patent['CompanyPatent']['pname'],"/companys/showpatent/".$id)."</td>";
											
											echo "<td>".$patent['type_id']['value']."</td>";
											$value = $patent['CompanyPatent']['state'];
											
											if($value == '0'){
												$m++;
											}elseif($value == '1'){
												$n++;
											}elseif($value == '2'){
												$l++;
											}elseif($value == '3'){
											    $k++;
											}
											$apply_time=$patent["CompanyPatent"]["apply_time"];
											$accept_time=$patent["CompanyPatent"]["accept_time"];
											$authorize_time=$patent["CompanyPatent"]["authorize_time"];
											$buy_time=$patent["CompanyPatent"]["buy_time"];
										
											echo "<td>".$str->getstaus($value)."/";
											echo $str->getstaustime($value, $apply_time, $accept_time, $authorize_time, $buy_time)."</td>";
											$created=$patent["CompanyPatent"]["created"];
											$created=date("Y-m-d",strtotime($created));
											echo "<td>".$created."</td>";
											echo "<td>";
											//if($isflag){
												echo $html->link(__("Edit",true),"/companys/editpatent/".$id,null,null);
												echo $html->link(__("Delete",true),"/companys/delpatent/".$id,array("onclick"=>"return doaction(this)"));
											//}else{
												//echo "<span class='enableaction'>编辑</span>";
												//echo "<span class='enableaction'>删除</span>";
											//}
											echo "</td>";
											echo "</tr>";
											$i++;
										}?>
						            </table>
								</div>
                        </div>
                    </li>
                    <script>
                    	$("#application<?php echo $y;?>").html('<?php echo $m; ?>个');
                    	$("#accept<?php echo $y;?>").html('<?php echo $n; ?>个');
                    	$("#authorized<?php echo $y;?>").html('<?php echo $l; ?>个');
                    	$("#buyed<?php echo $y;?>").html('<?php echo $k; ?>个');
					</script>
                    <?php } ?>
                </ul>
                <div id="issue_panel_arrow"></div>
                <div id="grad_left"></div>
				<div id="grad_right"></div>
                <a href="#" id="next">+</a>
                <a href="#" id="prev">-</a>
            </div>
        </div>
    </div>
</div>
<?php echo $this->element('actionconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>